import 'package:dio/dio.dart';
import 'package:flutter_bmfmap_example/http/http.dart';

class Loginserver{
  static Future<dynamic> login(String email,String password) async {
    Map<String, String> params = new Map();
    params["username"] = email;
    params["password"] = password;
    var result = await Http.post('/login', params: params);
    return result;
  }

  static Future<dynamic> regist(String nickname,String email,String password1,String password2) async {
    Map<String, String> params = new Map();
    params["nickname"] = nickname;
    params["email"] = email;
    params["password1"] = password1;
    params["password2"] = password2;
    var result = await Http.post('/register', params: params);
    print(result);
    return result;
  }

  static String regexEmail =
      "^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*\$";

  /// 检查是否是邮箱格式
  static bool isEmail(String input) {
    if (input == null || input.isEmpty) return false;
    return new RegExp(regexEmail).hasMatch(input);
  }

  

}

void main() {
    print(Loginserver.login('1904503593@qq.com', '123123123').then((value) => print(value)));
}